<template>
  <div>
    <!-- <CountTo :end-val="100">
      <span>总金额：</span>
    </CountTo> -->
    <CountTo ref="countNumber" :end-val="endVal" @on-animation-end="handleEnd">
      <span slot="left">总金额：</span>
      <span slot="right">元</span>
    </CountTo>
    <button @click="getNumber">获取数值</button>
    <button @click="updateNumber">更新数值</button>
  </div>
</template>
<script>
import CountTo from '_c/count-to'
export default {
  name: 'count_to',
  components: {
    CountTo
  },
  data () {
    return {
      endVal: 100
    }
  },
  methods: {
    getNumber () {
      this.$refs.countNumber.getCountTo()
    },
    updateNumber () {
      this.endVal += Math.random() * 100
    },
    handleEnd (endNum) {
      console.log('endNum -> ' + endNum)
    }
  }
}
</script>
